#!/usr/bin/env python
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library
use_library('django', '1.2')


from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
from model import GeneralM

class MainPage(webapp.RequestHandler):
    def get(self):
        viewVals = GeneralM.getViewVals()
        user = users.get_current_user()
        if not user:
            viewVals['promotion'] = self.promotion
            self.response.out.write(template.render('view/login.djhtml', viewVals))
        else:
            self.redirect("/allCourses")
    
    promotion = [
                    {'name': 'alert',
                     'heading': "Maintain attention",
                     'detail': 'Keep your students involved, alert and attentive during class with closed questions about the current subject.'},
                    {'name': 'time',
                     'heading': 'Instant feedback',
                     'detail': 'Save precious time and avoid checking quizzes!<br />studyWise&copy; check them instantly, providing you with results.'},
                    {'name': 'reward',
                     'heading': "Reward students",
                     'detail': 'Motivate students to participate and learn by rewarding good work with positive feedback.'},
                    {'name': 'money',
                     'heading': 'Save on expenses!',
                     'detail': 'Why spend money buying similar gadgets or subscriptions?<br />Use studyWise&copy; free of charge now.'},
                    {'name': 'cell',
                     'heading': 'Accessible',
                     'detail': 'Works with any smartphone, laptop or tablet.<br />No installation required.'},
                    {'name': 'share',
                     'heading': 'Share with colleagues',
                     'detail': 'Share topics, quizes or course statistics with colleagues.<br />See how your assistants are doing.'},
                    {'name': 'statistics',
                     'heading': 'Statistics',
                     'detail': 'Get helpful info about your students understanding of the learning material today.'}
                ]
              

application = webapp.WSGIApplication([(r'.*', MainPage)],debug=True)

def main():
    run_wsgi_app(application)
    
if __name__ == '__main__':
    main()